#include<stdio.h>

int main(void)
{
	char t;
	int n,a=0,b=0,c=0;

	/* 排序顺出，需要*/
	int max=0,min=0;
	int maxNumLetter='a', minNumLetter='c';
	scanf("%d",&n);

	/*读完当前行*/
	while((t=getchar())!='\n');

	while(n--)
	{
		scanf("%c",&t);
		switch(t)
		{
			case 'A':
			case 'a':
				a++;
				break;
			case 'B':
			case 'b':
				b++;
				break;
			case 'C':
			case 'c':
				c++;
				break;
			default:
				break;
		}
	}
	/* 还要排序输出 */
	max=a;
	maxNumLetter='a';
	if(b>max)
	{
		max=b;
		maxNumLetter='b';
	}
	if(c>max)
	{
		max=c;
		maxNumLetter='c';
	}

	min=c;
	minNumLetter='c';
	if(b<min)
	{
		min=b;
		minNumLetter='b';

	}
	if(a<min)
	{
		min=a;
		minNumLetter='a';
	}
	printf("%c %d\n",maxNumLetter,max);
	printf("%c %d\n",'a'+'b'+'c'-maxNumLetter-minNumLetter,a+b+c-max-min);
	printf("%c %d\n",minNumLetter,min);
	return 0;
}
